<?php

/**
 * This is the model class for table "lths_saletype".
 *
 * The followings are the available columns in table 'lths_saletype':
 * @property integer $saletype_code
 * @property string $saletype_name
 * @property string $channel_no
 * @property string $remark
 * @property string $create_time
 * @property string $update_time
 */
class Saletype extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Saletype the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'lths_saletype';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('saletype_code', 'numerical', 'integerOnly'=>true),
			array('saletype_name', 'length', 'max'=>50),
			array('channel_no', 'length', 'max'=>10),
			array('remark', 'length', 'max'=>200),
			array('create_time, update_time', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('saletype_code, saletype_name, channel_no, remark, create_time, update_time', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'saletype_code' => 'Saletype Code',
			'saletype_name' => 'Saletype Name',
			'channel_no' => 'Channel No',
			'remark' => 'Remark',
			'create_time' => 'Create Time',
			'update_time' => 'Update Time',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('saletype_code',$this->saletype_code);
		$criteria->compare('saletype_name',$this->saletype_name,true);
		$criteria->compare('channel_no',$this->channel_no,true);
		$criteria->compare('remark',$this->remark,true);
		$criteria->compare('create_time',$this->create_time,true);
		$criteria->compare('update_time',$this->update_time,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}